<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>发动机试车信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wFadongjiTable" lay-filter="wFadongjiTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wFadongjiHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">

            <@f.a alias="fdjsjxxdcxz" event="export" css="layui-btn layui-btn-sm" >
                <span>导出</span>
            </@f.a>

        </div>
        <form class="layui-form" action="" lay-filter="wFadongjiQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">数据来源部门</label>
                        <div class="layui-input-block">
                            <select  class="layui-input filter-value"  lay-verify="required" lay-search=""  name="Q_filldeptHospitalId_SL" placeholder="请输入"/></select>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">发动机名称</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_fdjmc_SL" placeholder="请输入"/>
                            </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">试车开始日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input start_time2 filter-value" name="Q_beginSjrq_DL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">试车结束日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input end_time2 filter-value" name="Q_endSjrq_DE" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">发动机代号</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_fdjdh_SL" placeholder="请输入"/>
                            </div>
                    </div>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">发动机编号</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_fdjbh_SL" placeholder="请输入"/>
                            </div>
                    </div>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">研制阶段</label>
                            <div class="layui-input-block">
                                <@dicSelect.dic name="Q_yzjd_SL" css="layui-input filter-value" verify="required" nodeKey="fdjsjyzjd" />
                            </div>
                    </div>

                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wFadongjiRightToolsBar">
    <@f.a alias="fdjsjxq" event="particulars" css="RightBtn">详情</@f.a>

</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer','common'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('wFadongjiTable');

        var tableH=publicMethods.tabHeight();

        //第一个实例
        table.render({
            elem: '#wFadongjiTable'
            ,height:tableH
            ,url: '${ctx}/qbdms/wFadongji/list'
            ,page: publicMethods.pageFun() //开启分页
            ,defaultToolbar: ['']
            ,toolbar: '#wFadongjiHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,limit:20
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left',minWidth:'90'}
                ,{field: 'filldeptHospital', title: '数据来源单位',sort:false, sortname: 'filldeptHospital',minWidth:'140'}
                ,{field: 'fdjmc', title: '发动机名称',sort:false, sortname: 'fdjmc',minWidth:'140'}
                ,{field: 'fdjdh', title: '发动机代号',sort:false, sortname: 'fdjdh',minWidth:'140'}
                ,{field: 'fdjbh', title: '发动机编号',sort:false, sortname: 'fdjbh',minWidth:'140'}
                ,{field: 'yzjd', title: '研制阶段',sort:false, sortname: 'yzjd',minWidth:'140'}
                ,{
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wFadongjiRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
                //-- 页面初始化状态 开始 ------------------------------------------------------------------
                // $(".layui-icon-up").trigger("click");
                //-- 页面初始化状态 结束 ------------------------------------------------------------------
                table.resize('wFadongjiTable');
            },parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['filldepthospital']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wFadongjiTable',true);
        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wFadongjiTable","wFadongjiQueryForm",{where:{}},isClear,false,20);
            var originOrgList = eval('${originOrgList}'); //数据来源单位
            common.initDicData("Q_filldeptHospitalId_SL", originOrgList, "");
        }

        table.on('toolbar(wFadongjiTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wFadongji/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    function open(url , param){
                        var curUrl = url;
                        layer.open({
                            type: 2,
                            area: ['700px', '520px'],
                            title: ['自定义导出', 'font-size:14px;'],
                            content:  '${ctx}/qbdms/wFadongji/view/export',
                            btnAlign: 'c',
                            skin: 'qbdms-layerFormBtn',
                            btn: ['确定', '取消'],
                            yes: function(index, layero){
                                url = curUrl;
                                var iframeWin = window["layui-layer-iframe" + index];
                                var data = iframeWin.getData();
                                if(data){
                                    url = url + "?data=" + JSON.stringify(data) + param;
                                    window.location.href = encodeURI(url)
                                }
                            }
                        });
                    }
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wFadongji/exportData';
                            var param = "";
                            $("form[lay-filter='wFadongjiQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url, param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url =  '${ctx}/qbdms/wFadongji/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    layer.open({
                        type: 2,
                        title: "导入",
                        shade: 0.3,
                        area: ['400px', '300px'],
                        content:+ "${ctx}/qbdms/wFadongji/view/import"
                        ,end:function () {
                            table.reload('wFadongjiTable', {
                                page: {
                                    curr: 1
                                }
                            });
                            dateReflash();
                        }
                    });
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wFadongjiTable');
                    dateReflash();
                    form.render();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wFadongjiTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = '${ctx}/qbdms/wFadongji/view/add?id='+data.id
                    break;
                case "particulars":
                    window.location.href =  '${ctx}/qbdms/wFadongji/view/particulars?id='+data.id+'&dof='+data.dataOriginFlag;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/wFadongji/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wFadongjiTable",{show:window.Initialization});

        var originOrgList = eval('${originOrgList}'); //数据来源单位
        common.initDicData("Q_filldeptHospitalId_SL", originOrgList, "");
    });
</script>
</body>
</html>